createDevice
Create a digital image of a device and link it to the IoT platform
This method allows machine controls to be represented as a device in the IoT platform and thus the transferred process parameters to be placed in relation to a specific workplace and the operations executed on it. For this purpose, a new device is created in the IoT platform and assigned to a workplace. Furthermore, it is possible to link to both the telemetric data transmitted online and the telemetric data recorded in the past. Both are specified as externalDataSources when the device is created.
/devices
Usage and SDK Samples
curl -X POST "https://localhost:24080/ffwebservices/hub/v1/devices"
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.DeviceApi;
import java.io.File;
import java.util.*;
public class DeviceApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2schema
OAuth oauth2schema = (OAuth) defaultClient.getAuthentication("oauth2schema");
oauth2schema.setAccessToken("YOUR ACCESS TOKEN");
DeviceApi apiInstance = new DeviceApi();
DeviceCreationRequestBody device = ; // DeviceCreationRequestBody | The properties of the device to be created
try {
device result = apiInstance.createDevice(device);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeviceApi#createDevice");
e.printStackTrace();
}
}
}
import io.swagger.client.api.DeviceApi;
public class DeviceApiExample {
public static void main(String[] args) {
DeviceApi apiInstance = new DeviceApi();
DeviceCreationRequestBody device = ; // DeviceCreationRequestBody | The properties of the device to be created
try {
device result = apiInstance.createDevice(device);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeviceApi#createDevice");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure OAuth2 access token for authorization: (authentication scheme: oauth2schema)
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
DeviceCreationRequestBody *device = ; // The properties of the device to be created
DeviceApi *apiInstance = [[DeviceApi alloc] init];
// Create a digital image of a device and link it to the IoT platform
[apiInstance createDeviceWith:device
completionHandler: ^(device output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var BridgeIoTHub = require('bridge_io_t_hub');
var defaultClient = BridgeIoTHub.ApiClient.instance;
// Configure OAuth2 access token for authorization: oauth2schema
var oauth2schema = defaultClient.authentications['oauth2schema'];
oauth2schema.accessToken = "YOUR ACCESS TOKEN"
var api = new BridgeIoTHub.DeviceApi()
var device = ; // {DeviceCreationRequestBody} The properties of the device to be created
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.createDevice(device, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class createDeviceExample
{
public void main()
{
// Configure OAuth2 access token for authorization: oauth2schema
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new DeviceApi();
var device = new DeviceCreationRequestBody(); // DeviceCreationRequestBody | The properties of the device to be created
try
{
// Create a digital image of a device and link it to the IoT platform
device result = apiInstance.createDevice(device);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling DeviceApi.createDevice: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: oauth2schema
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new Swagger\Client\Api\DeviceApi();
$device = ; // DeviceCreationRequestBody | The properties of the device to be created
try {
$result = $api_instance->createDevice($device);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DeviceApi->createDevice: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::DeviceApi;
# Configure OAuth2 access token for authorization: oauth2schema
$WWW::SwaggerClient::Configuration::access_token = 'YOUR_ACCESS_TOKEN';
my $api_instance = WWW::SwaggerClient::DeviceApi->new();
my $device = WWW::SwaggerClient::Object::DeviceCreationRequestBody->new(); # DeviceCreationRequestBody | The properties of the device to be created
eval {
my $result = $api_instance->createDevice(device => $device);
print Dumper($result);
};
if ($@) {
warn "Exception when calling DeviceApi->createDevice: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: oauth2schema
swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the API class
api_instance = swagger_client.DeviceApi()
device = # DeviceCreationRequestBody | The properties of the device to be created
try:
# Create a digital image of a device and link it to the IoT platform
api_response = api_instance.create_device(device)
pprint(api_response)
except ApiException as e:
print("Exception when calling DeviceApi->createDevice: %s\n" % e)
Parameters
| Name | Description |
|---|---|
| device * |
Responses
Status: 201 - Device created
| Name | Type | Format | Description |
|---|---|---|---|
| Location | String | Path to the device |